package com.hy.jpa.connection;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.IndexColumn;

import com.hy.mydesktop.shared.persistence.domain.gxt.GxtAppEventType;
import com.hy.mydesktop.shared.persistence.domain.gxt.ItemOfAssociateToWindow;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.ComponentMetaDataConstants;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.sun.org.apache.bcel.internal.generic.NEW;

//@Entity
@Table(name="t1")
public class T extends MyBaseModel{
	String name=null;
	public T() {
		super();
		// TODO Auto-generated constructor stub
	}
	public T(String name) {
		super();
		setName(name);
		// TODO Auto-generated constructor stub
	}
	public T(Map<String, Object> properties) {
		super(properties);
		// TODO Auto-generated constructor stub
	}
	/*String id;
	
	@Id
	@GeneratedValue
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}*/
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	/*@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name="parent_identifier")
	public T getParentItem ( )
	{
		return this.get (ComponentMetaDataConstants.PARENT_ITEM ) ;
	}
	
	public void setParentItem (T parentItem )
	{
		this.set (ComponentMetaDataConstants.PARENT_ITEM,  parentItem) ;
	}*/
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@IndexColumn(name="list_index")
	@JoinColumn(name="parent_identifier")

	
	//@OneToMany(mappedBy="parentItem",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	//@IndexColumn(name="list_index")
	public List<T> getChildrenItems ( )
	{
		return this.get (ComponentMetaDataConstants.CHILDREN_ITEMS ) ;
	}
	
	public void setChildrenItems (List<T> childrenItems )
	{
		this.set (ComponentMetaDataConstants.CHILDREN_ITEMS,  childrenItems) ;
	}
	
	
	
//	@ManyToMany(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH},fetch=FetchType.EAGER)
	@ManyToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
//	@JoinColumn(name="GxtComponentMetaNodeModel_identifier")
	public Set<M_TO_M> getRegisterEventTypes() {
//		return super.get("registerEventTypes");
		return super.get(MetaDataConstants.APP_EVENT_TYPES);
	}

	public void setRegisterEventTypes(Set<M_TO_M> registerEventTypes) {
		super.set(MetaDataConstants.APP_EVENT_TYPES, registerEventTypes);
	}
	
	
	@OneToMany(cascade={CascadeType.REMOVE,CascadeType.ALL},fetch=FetchType.EAGER)
	@JoinColumn(name="t_identifier")
	public List<T2> getList2() {
		return list2;
	}
	public void setList2(List<T2> list2) {
		this.list2 = list2;
	}
	@OneToMany(cascade={CascadeType.REMOVE,CascadeType.ALL},fetch=FetchType.EAGER)
	@JoinColumn(name="t_identifier")
	@IndexColumn(name = "t3_list_index")
	public List<T3> getList3() {
		return list3;
	}
	public void setList3(List<T3> list3) {
		this.list3 = list3;
	}
	List<T2> list2= new ArrayList<T2>();
	List<T3> list3= new ArrayList<T3>();

}
